//采用juqery后重写 del 和foreverdel
function del(id){
	var keyValue;
	if (id)
	{
	keyValue = id;
	}else {
	keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
	alert('请选择删除项！');
	return false;
	}
	if (window.confirm('确实要删除选择项吗？'))
	{
	$.post(URL+"/delete/","id="+keyValue+'&ajax=1',function(data){
			$.messager.show({title:'提示信息',msg:data.info,timeout:2000,showType:'slide'});
			window.location.reload();
		}//function
		,"json");//post	
	}
} 
//永久删除
function foreverdel(id){
	var keyValue;
	if (id)
	{
	keyValue = id;
	}else {
	keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
	alert('请选择删除项！');
	return false;
	}
	$.messager.confirm('确认窗口', '确实要永久删除选择项吗？', function(r){
				if (r){
					$.post(URL+"/foreverdelete/","id="+keyValue+'&ajax=1',function(data){
						$.messager.show({title:'提示信息',msg:data.info,timeout:2000,showType:'slide'});
						window.location.reload();
					}//function
					,"json");//post	
				}
	});
} 

function mouseover(e){

}
function mouseout(e){

}
function change(e){
	
}
function goUrl(x){       
     window.location.href=x;       
}      
function getLocalTime(nS) {   
		t = new Date(parseInt(nS) * 1000);
		return t.getFullYear()+'-'+(t.getMonth()+1)+'-'+t.getDate();
} 
function sortBy (field,sort){
	location.href = "?_order="+field+"&_sort="+sort;
}
function cache(){
	ThinkAjax.send(URL+'/cache','ajax=1');
}
function forbid(id){
	location.href = URL+"/forbid/id/"+id;
}
function recycle(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValue();
	}
	if (!keyValue)
	{
		alert('请选择要还原的项目！');
		return false;
	}
	location.href = URL+"/recycle/id/"+keyValue;
}
function resume(id){
	location.href = URL+"/resume/id/"+id;
}
function trace(id){
	location.href = URL+"/trace/id/"+id;
}
function output(){
	location.href = URL+"/output/";
}
function read(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValue();
	}
	if (!keyValue)
	{
		alert('请选择编辑项！');
		return false;
	}
	location.href =  URL+"/read/id/"+keyValue;
}

function edit(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValue();
	}
	if (!keyValue)
	{
		alert('请选择编辑项！');
		return false;
	}
	location.href =  URL+"/edit/id/"+keyValue;
}
function slidemessage(msg){
	$.messager.show({
				title:'消息提示',
				msg:msg,
				showType:'slide'
	});
}

//以下代码为项目专用函数，可能不适宜所有项目使用/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
//showDetails,showFancybox弹出显示框，主要用于index页面的详细信息显示，a为jquery选择器对象如a = $('#hideImage a');，t为标题，如'效果图片‘
function showDetails(i,ff){
	//i为要读取的ID,f为要读取的字段，t为显示的标题
	f = ff?ff:$('#showField').val();
	t = $('#showFieldTitle').val();
	$.post('__URL__/myGetField/',{id:i,f:f},function(d){
		$('#hideDiv').html(d.data);
		if($('#hideDiv img').length>0){
			img = $('#hideDiv img').detach();//将返回数据的图片取出放入hideImage中
			$('#hideImage').html(img);
			$('#hideImage img').each(function(i){
				src	= this.src;	
				title	= this.alt+"<br>"+$('#hideDiv').html();	//标题由a标签的alt和html()里面的
				if(!$(this).parent().is('a')){
					$(this).wrap("<a href='"+ src +"' class='iGallay' rel='pmt' title='"+ title +"'></a>");
				}
			})//each
			a = $('#hideImage a');
		}else{
			$('#hideDiv').html($('#hideDiv').html()).width(555);
			a = $('#hideDiv');
		}
		//alert($('#hideDiv').html());
		showFancybox(a,t);
	},'json')
}

function showFancybox(a,t){
	if(a.size()>0){
		$.fancybox( a ,{fitToView:true,openEffect:'fade',loop:false,autoScale:true,minWidth:610,
			helpers:{title:{type:'inside' }},
			afterLoad : function() {
				this.title = '['+t+' ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' ] ' + this.title : '');
			}//function
		});	//fancybox
	}else{
		$.messager.show({title:'提示信息',msg:'没有查询到有相关信息！',timeout:2000,showType:'slide'});	
	}
} 
//显示编辑器，n控件名，w宽度，h高度，将div_n的html()内容自动加载为编辑器内容
function showEditor(n,w,h){
	var ww = w>0?w:880;
	var hh = h>0?h:500;
	jQuery('#div_'+n).html("<TEXTAREA class=''  name='"+n+"' id='"+n+"'>"+$('#div_'+n).html()+"</textarea>");
	edt = KindEditor.create('textarea[name='+ n +']', {
		width:'100%',height:hh+'',allowFileManager:true,
		items : [
			'source','fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
			'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
			'insertunorderedlist', '|', 'emoticons', 'image', 'link','flash','media','insertfile','map']
	});	
	return edt;
}
